using System;
using CommandSystem;
using RgCore.Modules;

namespace RgCore.Commands.ModuleCommands
{
    public class Enable : ICommand
    {
        public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
        {
            if (!sender.CheckPermission(PlayerPermissions.ServerConsoleCommands))
            {
                response = "你没有权限执行此命令";
                return false;
            }

            if (!ModuleManager.IsDisable(arguments.At(0)))
            {
                response = "未找到此插件,可能是未安装或者未禁用.";
                return false;
            }

            ModuleManager.EnablePlugin(arguments.At(0), true);
            response = "成功启用此插件";
            return true;
        }

        public string Command { get; } = "enable";
        public string[] Aliases { get; } = Array.Empty<string>();
        public string Description { get; } = "启用一个插件";
    }
}